package com.sumainfor.pc.gmio.controller.director;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.common.utlis.PageUtils;
import com.sumainfor.common.utlis.Pager;
import com.sumainfor.pc.gmio.service.DiDeferredApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 *延期
 */
@RestController
@RequestMapping("/director/DiDeferredApply")
public class DiDeferredApplyController implements Serializable {
    @Autowired
    private DiDeferredApplyService diDeferredApplyService;
    /**
     * 查询延期申请
     */
    @GetMapping("/getDiDeferredApplyList")
    public JsonResult getDiDeferredApplyList(@RequestParam Map<String,Object>params,Pager pager){
        JsonResult result=new JsonResult();
        pager.setPagerNecessary(params, pager);
        PageUtils pageUtils = new PageUtils();
        Integer cout=diDeferredApplyService.getDiDeferredApplyListCount(params);
        if(cout==0){
            return pageUtils.getJsonResult(new ArrayList<Map<String,Object>>(), params,cout);
        }
        List<Map<String,Object>> getCommunityList=diDeferredApplyService.getDiDeferredApplyList(params);
        result=pageUtils.getJsonResult(getCommunityList, params, cout);
        return result;
    }
    /**
     * 租客端变更租约查询是否发起过延期退
     */
    @GetMapping("/key/getDiDaCount")
    public JsonResult getDiDaCount(@RequestParam Map<String, Object> params) {
        JsonResult result=new JsonResult();
        Integer count=diDeferredApplyService.getDiDaCount(params);
        if (count!=null){
            result.put(count);
        }else{
            result.putFailed("服务器繁忙");
        }
        return result;
    }
}
